// reactive
import { computed } from 'vue'
// store
import { useLeftBarStore } from '@/stores/leftBar.ts'
// router
import router from '@/router'

export default function leftBar() {
  const leftBarStore = useLeftBarStore()

  const leftBarClass = computed(() => leftBarStore.sideBarState)

  const leftBarOpenStyle = computed(() => {
    if (leftBarClass.value === 'close') {
      return {
        display: 'none',
      }
    } else {
      return {
        display: 'block',
      }
    }
  })

  const handleOpenSideBar = () => {
    leftBarStore.setSideBarState('open')
  }
  const handleCloseSideBar = () => {
    leftBarStore.setSideBarState('close')
  }

  const openNewChatPage = () => {
    router.push('/index')
  }

  // console.log('router', router)
  return {
    leftBarClass,
    leftBarOpenStyle,
    handleOpenSideBar,
    handleCloseSideBar,
    openNewChatPage,
  }
}
